<template>

  <transition name="fade">
    <div

        :style="{top:top,left:left}"
        v-if="showArea"
        ref="sectionRef"
        class="area-drop tw-z-50  tw-w-428  tw-bg-white tw-absolute tw-pt-20 tw-px-20 border-box font-small tw-overflow-auto "
    >
      <p class=" text-[#171920] click font-normal  tw-mb-20">点击选择地区</p>
      <div class="flex  tw-flex-wrap tw-w-384">
        <div
            v-for="(item, index) in areaTypeList"
            :key="item.id"
            :class="
            currentArea.id == item.id
              ? 'bg-color-theme tw-text-[#ffffff]'
              : 'tw-text-[#171920] hover:tw-text-[#fff] hover:tw-bg-[#04addb] '
          "
            class="flex tw-mr-20 tw-mb-20" style="border-radius: 4px"
            @click="changeArea(item)"
        >
        <span

            class=" tw-min-w-48 tw-h-32 flex-all-center  font-small  "
        >{{ item.name }}</span
        >
        </div>
        <div class="tw-flex-1"></div>
      </div>
    </div>
  </transition>

</template>

<script setup>
import {ref} from "vue";

defineProps({
  areaTypeList: {
    type: Array,
    default: [],
  },
  currentArea: {
    type: Object,
    default: {},
  },
  top: {
    type: String,
    default: '70px'
  },
  left: {
    type: String,
    default: '0px'
  }
});

const changeArea = (item) => {
  showArea.value=false
  emit("changeArea", item);
};
const emit = defineEmits(["changeArea"]);
let showArea = ref(false)
const openAreaDialog = (type) => {
  if(type==2){  showArea.value = !showArea.value}else{
    showArea.value = false
  }
}

defineExpose({openAreaDialog})
</script>

<style lang="scss" scoped>
.area-drop {
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
}

.fade-leave,   // 离开前,进入后透明度是1
.fade-enter-to {
  opacity: 1;
}
.fade-leave-active,
.fade-enter-active {
  transition: all 0.5s; //过度是2秒
}
.fade-leave-to,
.fade-enter {
  opacity: 0;
}
</style>
